<html>
<head><meta charset="utf-8"><title>what is CURRENT_DEPTH · rustdoc · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/index.html">rustdoc</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/what.20is.20CURRENT_DEPTH.html">what is CURRENT_DEPTH</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="228648074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/what%20is%20CURRENT_DEPTH/near/228648074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/what.20is.20CURRENT_DEPTH.html#228648074">(Mar 03 2021 at 19:03)</a>:</h4>
<p>What is <code>CURRENT_DEPTH</code>? There's a comment in the HTML renderer about it:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">        </span><span class="c1">// A little unfortunate that this is done like this, but it sure</span>
<span class="w">        </span><span class="c1">// does make formatting *a lot* nicer.</span>
<span class="w">        </span><span class="n">CURRENT_DEPTH</span><span class="p">.</span><span class="n">with</span><span class="p">(</span><span class="o">|</span><span class="n">slot</span><span class="o">|</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">slot</span><span class="p">.</span><span class="n">set</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">current</span><span class="p">.</span><span class="n">len</span><span class="p">());</span><span class="w"></span>
<span class="w">        </span><span class="p">});</span><span class="w"></span>
</code></pre></div>
<p>but I'm not sure what it means by "it sure does make formatting <em>a lot</em> nicer". It seems like it's used to find how nested the current item is, and it's used for <code>../</code> links?</p>



<a name="228648432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/what%20is%20CURRENT_DEPTH/near/228648432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/what.20is.20CURRENT_DEPTH.html#228648432">(Mar 03 2021 at 19:05)</a>:</h4>
<p>It's used from <code>clean/types.rs</code>, which is a bit weird since IIUC <code>clean/types.rs</code> is supposed to be format-independent.</p>



<a name="228648490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/what%20is%20CURRENT_DEPTH/near/228648490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/what.20is.20CURRENT_DEPTH.html#228648490">(Mar 03 2021 at 19:05)</a>:</h4>
<p>Specifically it's used in <code>Item::links()</code>—maybe that should be moved to <code>html/render/</code>?</p>



<a name="228650865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/what%20is%20CURRENT_DEPTH/near/228650865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/what.20is.20CURRENT_DEPTH.html#228650865">(Mar 03 2021 at 19:20)</a>:</h4>
<p>Wow, <code>CURRENT_DEPTH</code> has literally been around since when <code>String</code> was called <code>StrBuf</code>... oh my</p>



<a name="228650948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/what%20is%20CURRENT_DEPTH/near/228650948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/what.20is.20CURRENT_DEPTH.html#228650948">(Mar 03 2021 at 19:20)</a>:</h4>
<p>And it was around when <code>StrBuf</code> was called <code>~str</code>...</p>



<a name="228651071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/what%20is%20CURRENT_DEPTH/near/228651071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/what.20is.20CURRENT_DEPTH.html#228651071">(Mar 03 2021 at 19:21)</a>:</h4>
<p>And it's been around since the beginning of the rustdoc HTML backend. No wonder it's so hard to refactor <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="228651142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/what%20is%20CURRENT_DEPTH/near/228651142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/what.20is.20CURRENT_DEPTH.html#228651142">(Mar 03 2021 at 19:21)</a>:</h4>
<p>Huh, apparently <code>rustdoc_ng</code>'s original backend was JSON</p>



<a name="228651398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/what%20is%20CURRENT_DEPTH/near/228651398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/what.20is.20CURRENT_DEPTH.html#228651398">(Mar 03 2021 at 19:23)</a>:</h4>
<p>Looks like <span class="user-mention silent" data-user-id="116015">Alex Crichton</span> is the one that added that "a little unfortunate" comment—<a href="https://github.com/rust-lang/rust/blame/4fd061c426902b0904c65e64a3780b21f9ab3afb/src/rustdoc_ng/html/render.rs#L460-L462">in 2013</a>.</p>



<a name="228654822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/what%20is%20CURRENT_DEPTH/near/228654822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/what.20is.20CURRENT_DEPTH.html#228654822">(Mar 03 2021 at 19:43)</a>:</h4>
<p>It was there when I arrived. It's about adding the <code>..</code> iirc</p>



<a name="228654851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/what%20is%20CURRENT_DEPTH/near/228654851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/what.20is.20CURRENT_DEPTH.html#228654851">(Mar 03 2021 at 19:43)</a>:</h4>
<p>Not sure why they used a global for that though...</p>



<a name="228707492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/what%20is%20CURRENT_DEPTH/near/228707492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/what.20is.20CURRENT_DEPTH.html#228707492">(Mar 04 2021 at 02:51)</a>:</h4>
<p>Yeah, unfortunately it's hard to remove now.</p>



<a name="228707509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/what%20is%20CURRENT_DEPTH/near/228707509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/what.20is.20CURRENT_DEPTH.html#228707509">(Mar 04 2021 at 02:51)</a>:</h4>
<p>But we'll figure it out!</p>



<a name="228707542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/what%20is%20CURRENT_DEPTH/near/228707542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/what.20is.20CURRENT_DEPTH.html#228707542">(Mar 04 2021 at 02:51)</a>:</h4>
<p>I do still feel confused about the "it sure makes formatting <em>a lot</em> nicer" comment, but oh well.</p>



<a name="228736060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/what%20is%20CURRENT_DEPTH/near/228736060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/what.20is.20CURRENT_DEPTH.html#228736060">(Mar 04 2021 at 08:46)</a>:</h4>
<p>It was another time, don't try to understand the past haha</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>